<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" href="../libs/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/denglu.css">
    <script src="../libs/jquery-3.5.1.min.js"></script>
    <script src="../libs/bootstrap/js/bootstrap.min.js"></script>
    
</head>
<body>
    <div class="formbox">  
    <form class="denglu">
        <div class="form-group">
          <label for="exampleInputEmail1">用户名</label>
          <input type="email" class="form-control username" id="exampleInputEmail1" placeholder="请输入用户名">
        </div>
        <div class="form-group">
          <label for="exampleInputPassword1">密码</label>
          <input type="password" class="form-control password" id="exampleInputPassword1" placeholder="请输入密码">
        </div>
        <button type="submit" class="btn btn-default login">登录</button>
        <button type="button" class="btn btn-default register">注册</button>
        <p class="feedback"></p>
      </form>
     
    </div>
    <script>
      $('.denglu .login').on('click',function(){
        const username=$('.denglu .username').val();
        const password= $('.denglu .password').val();
        // console.log(username,password);
        $.ajax({
          url:'../api/shop/login.php',
          method:'get',
          data:{username,password},
          success:resp=>{
           if(resp.code===200){
            const msg=$('.feedback').html(resp.body.msg)
            // console.log(resp.body.msg)
            window.open('../index.html','_self')
           }else{
             
           }
          },
          dataType:'json'
        })
      })
      $('.denglu .register').on('click',function(){
        window.open('register.html','_self')
      })
    </script>
</body>
</html>